<%@page import="java.util.ArrayList"%>
<%@page import="database.ProductDAO"%>
<%@page import="model.Category"%>
<%@page import="java.util.List"%>
<%@page import="model.Role"%>
<%@page import="model.Staff"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<%
    Staff staff = (Staff) session.getAttribute("staff");

    if (staff == null) {
        response.sendRedirect(request.getContextPath() + "/Administration");
    } else if (!staff.getRoleList().contains(new Role(2))) {
        response.sendRedirect(request.getContextPath() + "/Administration/home");
    } else {
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Warehousing Management</title>
        <link href="<%= request.getContextPath()%>/css/style_for_page.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/style_for_menu.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/style_addtion.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/adMenu.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/tHeaderFooter.css" rel="stylesheet" type="text/css"/>
    </head>
    <body class="container">
        <header>
            <div class="header"> 
                <%@include file="/include/mHeader.jsp" %>
            </div>
            <div class="adContent">
                <div class="adMenu">
                    <%@include file="/include/mMenu.jsp" %>
                </div>
            </div>
        </header>
            <div class="content2">
                    <div class="registerbg" >
                    <div class="registerForm">
                       
                        <h1>New Product</h1>  
                        <s:form action="addProduct" namespace="/Administration/Product">
                            <s:textfield name="name" label="Product Name" size="30" />
                            <s:textfield name="details" label="Product Detail" size="30" />
                            <s:textfield name="others" label="Other Information" size="30" />
                            <s:textfield name="summary" label="Product Summary" size="30" />
                            <s:select label="Select category" 
                            list="productCategories" 
                            name="yourproductCategory" cssStyle="width: 200px"/>
                             <s:hidden name="imageurl"/>
                            
                            <table>
                                <tr>
                                    <td>
                                        <s:reset value="Reset" cssStyle="width: 96px" theme="simple" />
                                    </td>
                                    <td>
                                        <s:submit  value="Add Product" cssStyle="width: 96px; margin-left: 132px" theme="simple" />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2"><s:actionerror /></td>
                                </tr>
                            </table>
                        </s:form>
                    </div>
                      <div class="registerTerms">
                  <s:form action="upload-file" method="post" enctype="multipart/form-data">    
                      <br>
                      <br>
                      <p> Select product image from your computer...  </p>
                      <br>
                      <s:file  name="userImage" />
                        <table>
                            <tr>
                                <td style="width: 100px; margin-right: 132px">
                                     <s:submit value="Upload Image" align="center" />
                                </td>
                            </tr>
                        </table>
                            </s:form>
                    </div>
                </div>
            </div>  
        <footer>
            <div id="footer">
         <%@include file="/include/iFooter.jsp" %>
    </div>   
        </footer>
        
    </body>
</html>
<%
    }
%>